<link href="/css/admin_display/login.css" rel="stylesheet"/>
<body background="" style="background-size: cover">
<div class="login">
	<h1>管理登录</h1>
	<form class="layui-form">
		<div class="layui-form-item">
			<input class="layui-input" id="username" name="username" placeholder="用户名" lay-verify="required" type="text" autocomplete="off">
		</div>
		<div class="layui-form-item">
			<input class="layui-input" id="pwd" name="password" placeholder="密码" lay-verify="required" type="password" autocomplete="off">
		</div>
		<button class="layui-btn login_btn" type="button" lay-filter="login" onclick="login()">登录</button>
	</form>
</div>
</body>
<script type="text/javascript" src="/js/admin_display/layui/layui.js"></script>
<script type="text/javascript" src="/js/md5.js"></script>
<script>
    function login() {
        var user_name = $('#username').val();
        var pwd = $('#pwd').val();
        if(!user_name || !pwd){
            alert('请输入用户名和密码');
            return 0;
        }
        pwd = hex_md5(pwd);
        $.ajax({
            url:'/index.php/admin_display/method/login',
            type:'post',
            dataType:'json',
            data:{'username':user_name,"pwd":pwd},
            success:function (res) {
                if(res.code === '1'){
                    window.location.href = '/index.php/admin_display/admin'
                }else{
                    alert(res.msg);
                }
            },error:function () {
                alert('服务出错了，请稍后重试');
            }
        })
    }
</script>